from rest_framework.generics import ListAPIView, RetrieveAPIView, UpdateAPIView

from meiduo_admin.good.order_serializsers import OrderInfoSerializer, OrderDetailSerializer, OrderStatusSerializser
from meiduo_admin.my_paginate import MyPageNumberPagination
from orders.models import OrderInfo


class OrderInfoView(ListAPIView):
    pagination_class = MyPageNumberPagination
    # queryset = OrderInfo.objects.all()
    serializer_class = OrderInfoSerializer

    def get_queryset(self):
        keyword = self.request.query_params.get('keyword','')
        return OrderInfo.objects.filter(order_id__contains=keyword).all()


class OrderDetailView(RetrieveAPIView):
    queryset = OrderInfo.objects.all()
    serializer_class = OrderDetailSerializer

class OrderStatusView(UpdateAPIView):
    queryset = OrderInfo.objects.all()
    serializer_class = OrderStatusSerializser